﻿Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient

Public Class frmTS_Tanggiam
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btnNew As System.Windows.Forms.Button
    Friend WithEvents btnSave As System.Windows.Forms.Button
    Friend WithEvents btnDelete1 As System.Windows.Forms.Button
    Friend WithEvents txtSophieu As System.Windows.Forms.TextBox
    Friend WithEvents txtGhiChu As System.Windows.Forms.TextBox
    Friend WithEvents BtnClose As System.Windows.Forms.Button
    ' Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView
    Friend WithEvents DataGridView1 As MyDataGridView
    Friend WithEvents MatinhDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents TentinhDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents MamienDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents DataSetFormDonBindingSource As System.Windows.Forms.BindingSource
    Friend WithEvents DataSetForm_Don As MEKONG.DataSetForm_Don
    Friend WithEvents Manhom As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents Tennhom As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents ghichu As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents Column1 As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents ngayct As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents tg As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents mats As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents tents As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents diengiai As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents soluong As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents trigia As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents khauhao As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtDiengiai As System.Windows.Forms.TextBox
    Friend WithEvents txtngayct As System.Windows.Forms.MaskedTextBox
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents CboTanggiam As System.Windows.Forms.ComboBox
    Friend WithEvents lblHTTT As System.Windows.Forms.Label
    Friend WithEvents cboMataisan As MTGCComboBox
    Friend WithEvents btn_cbo_nhom_taisan As System.Windows.Forms.Button
    Friend WithEvents txtTentaisan As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents txtSoluong As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents txtTrigia As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents txtKhauhao As System.Windows.Forms.TextBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents colsophieu As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colNgayct As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colTanggiam As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colMataisan As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colTentaisan As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colDiengiai As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colSoluong As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents dvt As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colTrigia As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colKhauhao As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents colGhichu As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents txtDVT As System.Windows.Forms.TextBox
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Btn_Lamtuoi As System.Windows.Forms.Button
    Friend WithEvents Btn_Edit As System.Windows.Forms.Button
    Friend WithEvents BtnIn As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmTS_Tanggiam))
        Dim DataGridViewCellStyle1 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle
        Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle
        Dim DataGridViewCellStyle3 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle
        Dim DataGridViewCellStyle4 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle
        Dim DataGridViewCellStyle5 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle
        Me.btnSave = New System.Windows.Forms.Button
        Me.txtGhiChu = New System.Windows.Forms.TextBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.txtSophieu = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.btnNew = New System.Windows.Forms.Button
        Me.btnDelete1 = New System.Windows.Forms.Button
        Me.BtnClose = New System.Windows.Forms.Button
        Me.BtnIn = New System.Windows.Forms.Button
        Me.DataGridView1 = New MEKONG.MyDataGridView
        Me.colsophieu = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colNgayct = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colTanggiam = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colMataisan = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colTentaisan = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colDiengiai = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colSoluong = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.dvt = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colTrigia = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colKhauhao = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.colGhichu = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.DataSetFormDonBindingSource = New System.Windows.Forms.BindingSource(Me.components)
        Me.DataSetForm_Don = New MEKONG.DataSetForm_Don
        Me.Column1 = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.ngayct = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.tg = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.mats = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.tents = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.diengiai = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.soluong = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.trigia = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.khauhao = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.Label3 = New System.Windows.Forms.Label
        Me.txtDiengiai = New System.Windows.Forms.TextBox
        Me.txtngayct = New System.Windows.Forms.MaskedTextBox
        Me.Label11 = New System.Windows.Forms.Label
        Me.CboTanggiam = New System.Windows.Forms.ComboBox
        Me.lblHTTT = New System.Windows.Forms.Label
        Me.cboMataisan = New MTGCComboBox
        Me.btn_cbo_nhom_taisan = New System.Windows.Forms.Button
        Me.txtTentaisan = New System.Windows.Forms.TextBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.txtSoluong = New System.Windows.Forms.TextBox
        Me.Label6 = New System.Windows.Forms.Label
        Me.txtTrigia = New System.Windows.Forms.TextBox
        Me.Label7 = New System.Windows.Forms.Label
        Me.txtKhauhao = New System.Windows.Forms.TextBox
        Me.Label8 = New System.Windows.Forms.Label
        Me.txtDVT = New System.Windows.Forms.TextBox
        Me.Label9 = New System.Windows.Forms.Label
        Me.Btn_Lamtuoi = New System.Windows.Forms.Button
        Me.Btn_Edit = New System.Windows.Forms.Button
        CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.DataSetFormDonBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.DataSetForm_Don, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'btnSave
        '
        Me.btnSave.BackColor = System.Drawing.Color.Transparent
        Me.btnSave.Image = CType(resources.GetObject("btnSave.Image"), System.Drawing.Image)
        Me.btnSave.Location = New System.Drawing.Point(235, 151)
        Me.btnSave.Name = "btnSave"
        Me.btnSave.Size = New System.Drawing.Size(85, 24)
        Me.btnSave.TabIndex = 4
        Me.btnSave.UseVisualStyleBackColor = False
        '
        'txtGhiChu
        '
        Me.txtGhiChu.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtGhiChu.Location = New System.Drawing.Point(86, 121)
        Me.txtGhiChu.MaxLength = 100
        Me.txtGhiChu.Name = "txtGhiChu"
        Me.txtGhiChu.Size = New System.Drawing.Size(830, 22)
        Me.txtGhiChu.TabIndex = 3
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(31, 122)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(54, 16)
        Me.Label4.TabIndex = 16
        Me.Label4.Text = "Ghi Chú"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'txtSophieu
        '
        Me.txtSophieu.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtSophieu.Location = New System.Drawing.Point(86, 40)
        Me.txtSophieu.MaxLength = 10
        Me.txtSophieu.Name = "txtSophieu"
        Me.txtSophieu.Size = New System.Drawing.Size(114, 22)
        Me.txtSophieu.TabIndex = 1
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(28, 42)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(57, 16)
        Me.Label2.TabIndex = 12
        Me.Label2.Text = "Số phiếu"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(276, 5)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(371, 24)
        Me.Label1.TabIndex = 11
        Me.Label1.Text = "GHI TĂNG GIẢM TÀI SẢN"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'btnNew
        '
        Me.btnNew.Image = CType(resources.GetObject("btnNew.Image"), System.Drawing.Image)
        Me.btnNew.Location = New System.Drawing.Point(146, 151)
        Me.btnNew.Name = "btnNew"
        Me.btnNew.Size = New System.Drawing.Size(85, 24)
        Me.btnNew.TabIndex = 5
        '
        'btnDelete1
        '
        Me.btnDelete1.Image = CType(resources.GetObject("btnDelete1.Image"), System.Drawing.Image)
        Me.btnDelete1.Location = New System.Drawing.Point(414, 151)
        Me.btnDelete1.Name = "btnDelete1"
        Me.btnDelete1.Size = New System.Drawing.Size(85, 24)
        Me.btnDelete1.TabIndex = 29
        '
        'BtnClose
        '
        Me.BtnClose.Image = CType(resources.GetObject("BtnClose.Image"), System.Drawing.Image)
        Me.BtnClose.Location = New System.Drawing.Point(681, 151)
        Me.BtnClose.Name = "BtnClose"
        Me.BtnClose.Size = New System.Drawing.Size(85, 24)
        Me.BtnClose.TabIndex = 30
        '
        'BtnIn
        '
        Me.BtnIn.Image = CType(resources.GetObject("BtnIn.Image"), System.Drawing.Image)
        Me.BtnIn.Location = New System.Drawing.Point(504, 151)
        Me.BtnIn.Name = "BtnIn"
        Me.BtnIn.Size = New System.Drawing.Size(85, 24)
        Me.BtnIn.TabIndex = 39
        '
        'DataGridView1
        '
        Me.DataGridView1.AllowUserToAddRows = False
        Me.DataGridView1.AllowUserToDeleteRows = False
        Me.DataGridView1.AllowUserToResizeColumns = False
        Me.DataGridView1.AutoGenerateColumns = False
        Me.DataGridView1.BackgroundColor = System.Drawing.Color.LightBlue
        DataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter
        DataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control
        DataGridViewCellStyle1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        DataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText
        DataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight
        DataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText
        DataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
        Me.DataGridView1.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle1
        Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
        Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.colsophieu, Me.colNgayct, Me.colTanggiam, Me.colMataisan, Me.colTentaisan, Me.colDiengiai, Me.colSoluong, Me.dvt, Me.colTrigia, Me.colKhauhao, Me.colGhichu})
        Me.DataGridView1.DataMember = "TS_tanggiam"
        Me.DataGridView1.DataSource = Me.DataSetFormDonBindingSource
        Me.DataGridView1.Location = New System.Drawing.Point(1, 186)
        Me.DataGridView1.Name = "DataGridView1"
        Me.DataGridView1.ReadOnly = True
        Me.DataGridView1.RowHeadersWidth = 25
        Me.DataGridView1.Size = New System.Drawing.Size(975, 386)
        Me.DataGridView1.TabIndex = 40
        '
        'colsophieu
        '
        Me.colsophieu.DataPropertyName = "sophieu"
        Me.colsophieu.HeaderText = "Số phiếu"
        Me.colsophieu.Name = "colsophieu"
        Me.colsophieu.ReadOnly = True
        Me.colsophieu.Width = 80
        '
        'colNgayct
        '
        Me.colNgayct.DataPropertyName = "ngayct"
        DataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter
        Me.colNgayct.DefaultCellStyle = DataGridViewCellStyle2
        Me.colNgayct.HeaderText = "Ngày CT"
        Me.colNgayct.Name = "colNgayct"
        Me.colNgayct.ReadOnly = True
        Me.colNgayct.Width = 75
        '
        'colTanggiam
        '
        Me.colTanggiam.DataPropertyName = "tg"
        Me.colTanggiam.HeaderText = "Tăng/giàm"
        Me.colTanggiam.Name = "colTanggiam"
        Me.colTanggiam.ReadOnly = True
        Me.colTanggiam.Width = 70
        '
        'colMataisan
        '
        Me.colMataisan.DataPropertyName = "mats"
        Me.colMataisan.HeaderText = "Mã TS"
        Me.colMataisan.Name = "colMataisan"
        Me.colMataisan.ReadOnly = True
        Me.colMataisan.Width = 60
        '
        'colTentaisan
        '
        Me.colTentaisan.DataPropertyName = "tents"
        Me.colTentaisan.HeaderText = "Tên TS"
        Me.colTentaisan.Name = "colTentaisan"
        Me.colTentaisan.ReadOnly = True
        Me.colTentaisan.Width = 170
        '
        'colDiengiai
        '
        Me.colDiengiai.DataPropertyName = "diengiai"
        Me.colDiengiai.HeaderText = "Diễn giải"
        Me.colDiengiai.Name = "colDiengiai"
        Me.colDiengiai.ReadOnly = True
        '
        'colSoluong
        '
        Me.colSoluong.DataPropertyName = "soluong"
        DataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight
        DataGridViewCellStyle3.Format = "N0"
        Me.colSoluong.DefaultCellStyle = DataGridViewCellStyle3
        Me.colSoluong.HeaderText = "Số lượng "
        Me.colSoluong.Name = "colSoluong"
        Me.colSoluong.ReadOnly = True
        Me.colSoluong.Width = 80
        '
        'dvt
        '
        Me.dvt.DataPropertyName = "dvt"
        Me.dvt.HeaderText = "ĐVT"
        Me.dvt.Name = "dvt"
        Me.dvt.ReadOnly = True
        Me.dvt.Width = 40
        '
        'colTrigia
        '
        Me.colTrigia.DataPropertyName = "trigia"
        DataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight
        DataGridViewCellStyle4.Format = "N0"
        Me.colTrigia.DefaultCellStyle = DataGridViewCellStyle4
        Me.colTrigia.HeaderText = "Trị giá"
        Me.colTrigia.Name = "colTrigia"
        Me.colTrigia.ReadOnly = True
        Me.colTrigia.Width = 80
        '
        'colKhauhao
        '
        Me.colKhauhao.DataPropertyName = "khauhao"
        DataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight
        DataGridViewCellStyle5.Format = "N0"
        Me.colKhauhao.DefaultCellStyle = DataGridViewCellStyle5
        Me.colKhauhao.HeaderText = "Khấu hao"
        Me.colKhauhao.Name = "colKhauhao"
        Me.colKhauhao.ReadOnly = True
        Me.colKhauhao.Width = 80
        '
        'colGhichu
        '
        Me.colGhichu.DataPropertyName = "ghichu"
        Me.colGhichu.HeaderText = "Ghi chú"
        Me.colGhichu.Name = "colGhichu"
        Me.colGhichu.ReadOnly = True
        Me.colGhichu.Width = 70
        '
        'DataSetFormDonBindingSource
        '
        Me.DataSetFormDonBindingSource.DataSource = Me.DataSetForm_Don
        Me.DataSetFormDonBindingSource.Position = 0
        '
        'DataSetForm_Don
        '
        Me.DataSetForm_Don.DataSetName = "DataSetForm_Don"
        Me.DataSetForm_Don.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
        '
        'Column1
        '
        Me.Column1.DataPropertyName = "sophieu"
        Me.Column1.HeaderText = "Column1"
        Me.Column1.Name = "Column1"
        '
        'ngayct
        '
        Me.ngayct.DataPropertyName = "ngayct"
        Me.ngayct.HeaderText = "ngayct"
        Me.ngayct.Name = "ngayct"
        '
        'tg
        '
        Me.tg.DataPropertyName = "tg"
        Me.tg.HeaderText = "tg"
        Me.tg.Name = "tg"
        '
        'mats
        '
        Me.mats.DataPropertyName = "mats"
        Me.mats.HeaderText = "mats"
        Me.mats.Name = "mats"
        '
        'tents
        '
        Me.tents.DataPropertyName = "tents"
        Me.tents.HeaderText = "tents"
        Me.tents.Name = "tents"
        '
        'diengiai
        '
        Me.diengiai.DataPropertyName = "diengiai"
        Me.diengiai.HeaderText = "diengiai"
        Me.diengiai.Name = "diengiai"
        '
        'soluong
        '
        Me.soluong.DataPropertyName = "soluong"
        Me.soluong.HeaderText = "soluong"
        Me.soluong.Name = "soluong"
        '
        'trigia
        '
        Me.trigia.DataPropertyName = "trigia"
        Me.trigia.HeaderText = "trigia"
        Me.trigia.Name = "trigia"
        '
        'khauhao
        '
        Me.khauhao.DataPropertyName = "khauhao"
        Me.khauhao.HeaderText = "khauhao"
        Me.khauhao.Name = "khauhao"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(31, 70)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(54, 19)
        Me.Label3.TabIndex = 14
        Me.Label3.Text = "Diễn giải"
        '
        'txtDiengiai
        '
        Me.txtDiengiai.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtDiengiai.Location = New System.Drawing.Point(86, 67)
        Me.txtDiengiai.MaxLength = 50
        Me.txtDiengiai.Name = "txtDiengiai"
        Me.txtDiengiai.Size = New System.Drawing.Size(830, 22)
        Me.txtDiengiai.TabIndex = 2
        '
        'txtngayct
        '
        Me.txtngayct.Location = New System.Drawing.Point(260, 40)
        Me.txtngayct.Mask = "00/00/0000"
        Me.txtngayct.Name = "txtngayct"
        Me.txtngayct.Size = New System.Drawing.Size(89, 20)
        Me.txtngayct.TabIndex = 1162
        Me.txtngayct.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(205, 42)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(56, 19)
        Me.Label11.TabIndex = 1161
        Me.Label11.Text = "Ngày CT"
        Me.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'CboTanggiam
        '
        Me.CboTanggiam.AllowDrop = True
        Me.CboTanggiam.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.CboTanggiam.FormattingEnabled = True
        Me.CboTanggiam.Location = New System.Drawing.Point(421, 40)
        Me.CboTanggiam.Name = "CboTanggiam"
        Me.CboTanggiam.Size = New System.Drawing.Size(81, 22)
        Me.CboTanggiam.TabIndex = 1163
        '
        'lblHTTT
        '
        Me.lblHTTT.AutoSize = True
        Me.lblHTTT.Location = New System.Drawing.Point(356, 42)
        Me.lblHTTT.Name = "lblHTTT"
        Me.lblHTTT.Size = New System.Drawing.Size(59, 13)
        Me.lblHTTT.TabIndex = 1164
        Me.lblHTTT.Text = "Tăng/giảm"
        '
        'cboMataisan
        '
        Me.cboMataisan.ArrowBoxColor = System.Drawing.SystemColors.Control
        Me.cboMataisan.ArrowColor = System.Drawing.Color.Black
        Me.cboMataisan.BindedControl = Nothing
        Me.cboMataisan.BorderStyle = MTGCComboBox.TipiBordi.Fixed3D
        Me.cboMataisan.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal
        Me.cboMataisan.ColumnNum = 1
        Me.cboMataisan.ColumnWidth = "121"
        Me.cboMataisan.DisabledArrowBoxColor = System.Drawing.SystemColors.Control
        Me.cboMataisan.DisabledArrowColor = System.Drawing.Color.LightGray
        Me.cboMataisan.DisabledBackColor = System.Drawing.SystemColors.Control
        Me.cboMataisan.DisabledBorderColor = System.Drawing.SystemColors.InactiveBorder
        Me.cboMataisan.DisabledForeColor = System.Drawing.SystemColors.GrayText
        Me.cboMataisan.DisplayMember = "Text"
        Me.cboMataisan.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cboMataisan.DropDownBackColor = System.Drawing.Color.FromArgb(CType(CType(193, Byte), Integer), CType(CType(210, Byte), Integer), CType(CType(238, Byte), Integer))
        Me.cboMataisan.DropDownForeColor = System.Drawing.Color.Black
        Me.cboMataisan.DropDownStyle = MTGCComboBox.CustomDropDownStyle.DropDown
        Me.cboMataisan.DropDownWidth = 141
        Me.cboMataisan.GridLineColor = System.Drawing.Color.LightGray
        Me.cboMataisan.GridLineHorizontal = False
        Me.cboMataisan.GridLineVertical = False
        Me.cboMataisan.LoadingType = MTGCComboBox.CaricamentoCombo.ComboBoxItem
        Me.cboMataisan.Location = New System.Drawing.Point(547, 40)
        Me.cboMataisan.ManagingFastMouseMoving = True
        Me.cboMataisan.ManagingFastMouseMovingInterval = 30
        Me.cboMataisan.Name = "cboMataisan"
        Me.cboMataisan.SelectedItem = Nothing
        Me.cboMataisan.SelectedValue = Nothing
        Me.cboMataisan.Size = New System.Drawing.Size(85, 21)
        Me.cboMataisan.TabIndex = 1168
        '
        'btn_cbo_nhom_taisan
        '
        Me.btn_cbo_nhom_taisan.Location = New System.Drawing.Point(634, 41)
        Me.btn_cbo_nhom_taisan.Name = "btn_cbo_nhom_taisan"
        Me.btn_cbo_nhom_taisan.Size = New System.Drawing.Size(24, 21)
        Me.btn_cbo_nhom_taisan.TabIndex = 1167
        Me.btn_cbo_nhom_taisan.Text = "...."
        Me.btn_cbo_nhom_taisan.UseVisualStyleBackColor = True
        '
        'txtTentaisan
        '
        Me.txtTentaisan.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtTentaisan.Location = New System.Drawing.Point(660, 40)
        Me.txtTentaisan.MaxLength = 50
        Me.txtTentaisan.Name = "txtTentaisan"
        Me.txtTentaisan.Size = New System.Drawing.Size(256, 22)
        Me.txtTentaisan.TabIndex = 1166
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(502, 42)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(57, 16)
        Me.Label5.TabIndex = 1165
        Me.Label5.Text = "Tài sản"
        Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'txtSoluong
        '
        Me.txtSoluong.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtSoluong.Location = New System.Drawing.Point(260, 94)
        Me.txtSoluong.MaxLength = 10
        Me.txtSoluong.Name = "txtSoluong"
        Me.txtSoluong.Size = New System.Drawing.Size(89, 22)
        Me.txtSoluong.TabIndex = 1169
        Me.txtSoluong.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(204, 96)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(57, 16)
        Me.Label6.TabIndex = 1170
        Me.Label6.Text = "Số lượng"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'txtTrigia
        '
        Me.txtTrigia.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtTrigia.Location = New System.Drawing.Point(421, 94)
        Me.txtTrigia.MaxLength = 10
        Me.txtTrigia.Name = "txtTrigia"
        Me.txtTrigia.Size = New System.Drawing.Size(211, 22)
        Me.txtTrigia.TabIndex = 1171
        Me.txtTrigia.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(367, 96)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(57, 16)
        Me.Label7.TabIndex = 1172
        Me.Label7.Text = "Trị giá"
        Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'txtKhauhao
        '
        Me.txtKhauhao.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtKhauhao.Location = New System.Drawing.Point(722, 94)
        Me.txtKhauhao.MaxLength = 10
        Me.txtKhauhao.Name = "txtKhauhao"
        Me.txtKhauhao.Size = New System.Drawing.Size(194, 22)
        Me.txtKhauhao.TabIndex = 1173
        Me.txtKhauhao.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(643, 96)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(57, 16)
        Me.Label8.TabIndex = 1174
        Me.Label8.Text = "Khấu hao"
        Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'txtDVT
        '
        Me.txtDVT.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtDVT.Location = New System.Drawing.Point(86, 94)
        Me.txtDVT.MaxLength = 10
        Me.txtDVT.Name = "txtDVT"
        Me.txtDVT.Size = New System.Drawing.Size(114, 22)
        Me.txtDVT.TabIndex = 1175
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(7, 96)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(73, 18)
        Me.Label9.TabIndex = 1176
        Me.Label9.Text = "Đơn vị tính"
        Me.Label9.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'Btn_Lamtuoi
        '
        Me.Btn_Lamtuoi.Image = CType(resources.GetObject("Btn_Lamtuoi.Image"), System.Drawing.Image)
        Me.Btn_Lamtuoi.Location = New System.Drawing.Point(592, 151)
        Me.Btn_Lamtuoi.Name = "Btn_Lamtuoi"
        Me.Btn_Lamtuoi.Size = New System.Drawing.Size(85, 24)
        Me.Btn_Lamtuoi.TabIndex = 1178
        '
        'Btn_Edit
        '
        Me.Btn_Edit.BackColor = System.Drawing.Color.Transparent
        Me.Btn_Edit.Image = CType(resources.GetObject("Btn_Edit.Image"), System.Drawing.Image)
        Me.Btn_Edit.Location = New System.Drawing.Point(324, 151)
        Me.Btn_Edit.Name = "Btn_Edit"
        Me.Btn_Edit.Size = New System.Drawing.Size(85, 24)
        Me.Btn_Edit.TabIndex = 1177
        Me.Btn_Edit.UseVisualStyleBackColor = False
        '
        'frmTS_Tanggiam
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.LightBlue
        Me.ClientSize = New System.Drawing.Size(977, 573)
        Me.Controls.Add(Me.Btn_Lamtuoi)
        Me.Controls.Add(Me.Btn_Edit)
        Me.Controls.Add(Me.txtDVT)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.txtKhauhao)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.txtTrigia)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.txtSoluong)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.cboMataisan)
        Me.Controls.Add(Me.btn_cbo_nhom_taisan)
        Me.Controls.Add(Me.txtTentaisan)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.CboTanggiam)
        Me.Controls.Add(Me.lblHTTT)
        Me.Controls.Add(Me.txtngayct)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.DataGridView1)
        Me.Controls.Add(Me.BtnIn)
        Me.Controls.Add(Me.BtnClose)
        Me.Controls.Add(Me.txtGhiChu)
        Me.Controls.Add(Me.txtDiengiai)
        Me.Controls.Add(Me.txtSophieu)
        Me.Controls.Add(Me.btnDelete1)
        Me.Controls.Add(Me.btnNew)
        Me.Controls.Add(Me.btnSave)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Name = "frmTS_Tanggiam"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Ghi Tang Giam Tai san"
        CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.DataSetFormDonBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.DataSetForm_Don, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region
    Private data1, dataHTThanhToan As DataTable
    Private da As MySqlDataAdapter
    Dim myDT As New DataTable
    Dim strError As String = ""
    Dim co_phim_tat As Boolean = False
    Dim myform As Form
    Dim sqlQuery As String = ""
    Dim co_tuoi As Integer = 0
    Sub SetclearData()
        Me.txtngayct.Text = Today
        Me.txtSophieu.Text = ""
        Me.txtSoluong.Text = "1"
        Me.txtTrigia.Text = "0"
        Me.txtKhauhao.Text = "0"
        Me.txtDiengiai.Text = ""
        Me.txtGhiChu.Text = ""
    End Sub
    Private Sub txtMa_Nhom_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtSophieu.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtngayct.Focus()
        End If
    End Sub
    Private Sub TxtTen_Nhom_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtngayct.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.CboTanggiam.Focus()
        End If
    End Sub
    Private Sub CboTanggiam_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CboTanggiam.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.cboMataisan.Focus()
        End If
    End Sub
    Private Sub cboMataisan_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cboMataisan.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtTentaisan.Focus()
        End If
    End Sub
    Private Sub txtTentaisan_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTentaisan.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtDiengiai.Focus()
        End If
    End Sub
    Private Sub txtDiengiai_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtDiengiai.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtDVT.Focus()
        End If
    End Sub
    Private Sub txtDVT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtDVT.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtSoluong.Focus()
        End If
    End Sub
    Private Sub txtSoluong_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtSoluong.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtTrigia.Focus()
        End If
    End Sub
    Private Sub txtTrigia_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTrigia.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtKhauhao.Focus()
        End If
    End Sub
    Private Sub txtGhiChu_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtKhauhao.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtGhiChu.Focus()
        End If
    End Sub
    Private Sub txtGhiChu_KeyDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtGhiChu.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.btnSave.Focus()
        End If
    End Sub
    Private Sub btnSave_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles btnSave.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.btnNew.Focus()
        End If
    End Sub
    Private Sub btnNew_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles btnNew.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.txtSophieu.Focus()
        End If
    End Sub

    Private Sub frmTS_Phongban_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        'edit = moduleConstants.edit
        'If edit = 0 Then
        '    '  MessageBox.Show("Bạn chưa được cấp quyền !", globalVariale.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information)
        'Else
        If Me.co_phim_tat = True Then
            If e.KeyCode = (e.Control And Keys.S) Then
                luu()
                Me.setReadonly(True, False, False)
            End If
            If e.KeyCode = (e.Control And Keys.D) Then
                xoa()
                Me.setReadonly(True, False, False)
            End If
        End If
        If e.KeyCode = (e.Control And Keys.N) Then
            SetclearData()
            txtSophieu.Focus()
            Me.setReadonly(False, True, True)
        End If
        If e.KeyCode = (e.Control And Keys.E) Then
            Me.setReadonly(False, True, True)
        End If
        If e.KeyCode = (e.Control And Keys.Q) Then
            Me.Close()
        End If
        If e.KeyCode = Keys.Escape Then
            Me.Close()
        End If
        If e.KeyCode = (e.Control And Keys.P) Then
            '  FrmCrTS_Phongban.Show()
        End If
        If e.KeyCode = (e.Control And Keys.R) Then
            If co_tuoi = 1 Then
                Me.loadTaisan()
            End If
            If co_tuoi = 0 Then
                Me.loadDanhSachNhomHangHoa("SELECT * FROM TS_tanggiam ")
            End If
        End If
    End Sub
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        luu()
        Me.setReadonly(True, False, False)
    End Sub
    
    Private Sub luu()
        ' Kiểm tra có nhập liệu chưa ?
        If Me.checkInput(txtSophieu.Text, txtTentaisan.Text) Then
            Dim txtMaTinh = Me.txtSophieu.Text.Trim
            sqlQuery = "SELECT sophieu FROM TS_tanggiam WHERE sophieu = '" & txtMaTinh & "'"
            'If moduleDatabaseConn.GetDataTable(sqlQuery).Rows.Count > 0 Then

            'End If
            Dim existedMaTinh As Integer = moduleDatabaseConn.CheckRecordExisted(sqlQuery)
            If existedMaTinh = 1 Then ' Update record
                If MessageBox.Show("Số phiếu này đã tồn tại ? Bạn muốn cập nhật không ? ", globalVariale.msgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = MsgBoxResult.Yes Then
                    sqlQuery = "UPDATE TS_tanggiam "
                    sqlQuery += "SET "
                    sqlQuery += "sophieu = '" & Me.txtSophieu.Text.Trim & "'"
                    sqlQuery += ", ngayct = '" & Format(CDate(Me.txtngayct.Text.Trim), "yyyy-MM-dd") & "'"
                    sqlQuery += ", tg = '" & Me.CboTanggiam.SelectedValue & "'"
                    sqlQuery += ", mats = '" & Me.cboMataisan.Text.Trim & "'"
                    sqlQuery += ", tents = '" & Me.txtTentaisan.Text.Trim & "'"
                    sqlQuery += ", diengiai = '" & Me.txtDiengiai.Text.Trim & "'"
                    sqlQuery += ", soluong = '" & Replace(CInt(Me.txtSoluong.Text.Trim), ",", ".") & "'"
                    sqlQuery += ", trigia = '" & Replace(CDec(Me.txtTrigia.Text.Trim), ",", ".") & "'"
                    sqlQuery += ", khauhao = '" & Replace(CDec(Me.txtKhauhao.Text.Trim), ",", ".") & "'"
                    sqlQuery += ", ghichu = '" & Me.txtGhiChu.Text.Trim & "'"
                    sqlQuery += ", dvt = '" & Me.txtDVT.Text.Trim & "'"
                    sqlQuery += " WHERE sophieu= '" & Me.txtSophieu.Text.Trim & "'"
                    Dim updated As Integer = moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
                    If updated = 1 Then
                        MessageBox.Show("Cập nhật thông tin thành công !")
                        sqlQuery = "SELECT * FROM TS_tanggiam"
                        Me.loadDanhSachNhomHangHoa(sqlQuery)
                    Else
                        MessageBox.Show("Cập nhật thông tin không thành công: " & globalVariale.sqlMsgError)
                    End If
                End If
            Else
                If existedMaTinh = 0 Then ' Insert record
                    sqlQuery = "INSERT INTO TS_tanggiam "
                    sqlQuery += "(sophieu,ngayct,tg,mats,tents,diengiai,soluong,trigia,khauhao,ghichu,dvt) "
                    sqlQuery += "VALUES "
                    sqlQuery += "("
                    sqlQuery += "'" & Me.txtSophieu.Text.Trim & "', "
                    sqlQuery += "'" & Format(CDate(Me.txtngayct.Text.Trim), "yyyy-MM-dd") & "', "
                    sqlQuery += "'" & Me.CboTanggiam.SelectedValue & "', "
                    sqlQuery += "'" & Me.cboMataisan.Text.Trim & "', "
                    sqlQuery += "'" & Me.txtTentaisan.Text.Trim & "', "
                    sqlQuery += "'" & Me.txtDiengiai.Text.Trim & "', "
                    sqlQuery += "'" & Replace(CDec(Me.txtSoluong.Text.Trim), ",", ".") & "', "
                    sqlQuery += "'" & Replace(CDec(Me.txtTrigia.Text.Trim), ",", ".") & "', "
                    sqlQuery += "'" & Replace(CDec(Me.txtKhauhao.Text.Trim), ",", ".") & "', "
                    sqlQuery += "'" & Me.txtGhiChu.Text.Trim & "',  "
                    sqlQuery += "'" & Me.txtDVT.Text.Trim & "' "
                    sqlQuery += ")"
                    Dim inserted As Integer = moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
                    If inserted = 1 Then
                        MessageBox.Show("Thêm thông tin thành công !")
                        sqlQuery = "SELECT * FROM TS_tanggiam"
                        Me.loadDanhSachNhomHangHoa(sqlQuery)
                    Else
                        MessageBox.Show("Thêm thông tin không thành công: " & globalVariale.sqlMsgError)
                    End If
                Else ' SQLExeption: existedMaQuocGia = -1
                    MessageBox.Show("Lấy dữ liệu bị lỗi: " & globalVariale.sqlMsgError, "Lấy dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                End If
            End If
        End If
    End Sub

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        SetclearData()
        txtSophieu.Focus()
        Me.setReadonly(False, True, True)
    End Sub
    Private Sub btnDelete1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete1.Click
        xoa()
        Me.setReadonly(True, False, False)
    End Sub
    Private Sub xoa()
        Dim txtMaTinh As String = Trim(Me.txtSophieu.Text)
        If txtMaTinh = "" Then
            MessageBox.Show("Bạn chưa chọn Mã để xóa !")
        Else
            Dim txtTenTinh As String = Trim(Me.txtDiengiai.Text)
            moduleConstants.MessageWarning = "Bạn có muốn xóa  " & txtMaTinh & "(" & txtTenTinh & ") ?"

            If MessageBox.Show(moduleConstants.MessageWarning, globalVariale.msgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = MsgBoxResult.Yes Then
                Dim sqlQuery As String = "DELETE FROM TS_tanggiam WHERE sophieu = '" & txtMaTinh & "'"
                Dim deleting As Integer = moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
                If deleting = 1 Then
                    MessageBox.Show("Xóa thông tin thành công !")
                    sqlQuery = "SELECT * FROM TS_tanggiam"
                    Me.loadDanhSachNhomHangHoa(sqlQuery)
                    SetclearData()
                Else
                    MessageBox.Show("Xóa thông tin không thành công: " & globalVariale.sqlMsgError)
                End If
            End If
        End If
    End Sub
    Private Sub loadTanggiam()
        dataHTThanhToan = New DataTable("HTThanhToan")
        dataHTThanhToan.Columns.Add("id")
        dataHTThanhToan.Columns.Add("name")
        dataHTThanhToan.Rows.Add(New String() {"tang", "Ghi tăng"})
        dataHTThanhToan.Rows.Add(New String() {"giam", "Ghi giàm"})
        Me.CboTanggiam.DataSource = dataHTThanhToan
        Me.CboTanggiam.DisplayMember = "name"
        Me.CboTanggiam.ValueMember = "id"
        Me.CboTanggiam.SelectedValue = 0
    End Sub
    Private Sub setReadonly(ByVal bien_text As Boolean, ByVal bien_com As Boolean, ByVal v_co_phim_tat As Boolean)

        Me.txtSophieu.ReadOnly = bien_text
        Me.txtngayct.ReadOnly = bien_text
        Me.txtTentaisan.ReadOnly = bien_text
        Me.txtDiengiai.ReadOnly = bien_text

        Me.txtSoluong.ReadOnly = bien_text
        Me.txtTrigia.ReadOnly = bien_text
        Me.txtKhauhao.ReadOnly = bien_text
        Me.txtGhiChu.ReadOnly = bien_text
        Me.txtDVT.ReadOnly = bien_text
     
        sqlQuery += ", tg = '" & Me.CboTanggiam.SelectedValue & "'"
        sqlQuery += ", mats = '" & Me.cboMataisan.Text.Trim & "'"
        Me.CboTanggiam.Enabled = bien_com
        Me.cboMataisan.Enabled = bien_com

        Me.btnDelete1.Enabled = bien_com
        Me.btnSave.Enabled = bien_com
        Me.co_phim_tat = v_co_phim_tat

        Me.btn_cbo_nhom_taisan.Enabled = bien_com
    End Sub
    Private Sub frmTS_Phongban_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        moduleUtils.setDinhDangVietNam()
        Me.KeyPreview = True
        Me.setReadonly(True, False, False)
        Me.loadDanhSachNhomHangHoa("SELECT * FROM TS_tanggiam")
        Me.loadTaisan()
        Me.loadTanggiam()

    End Sub
    Private Sub loadTaisan()
        Try
            sqlQuery = "SELECT ma, ten,dvt FROM TS_taisan ORDER BY ma "
            cboMataisan.Items.Clear()
            cboMataisan.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
            cboMataisan.ColumnNum = 3
            cboMataisan.ColumnWidth = "150;300;150"
            cboMataisan.HighlightBorderColor = Color.Black
            cboMataisan.GridLineHorizontal = True
            cboMataisan.GridLineVertical = True
            cboMataisan.ItemHeight = 17
            cboMataisan.DropDownHeight = 300
            cboMataisan.SourceDataTable = moduleDatabaseConn.GetDataTable(sqlQuery)
            cboMataisan.SelectedIndex = 0
        Catch ex As Exception
        End Try
    End Sub
    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        Me.Close()
    End Sub
    Private Sub BtnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnIn.Click
        'FrmCrTS_Phongban.Show()
    End Sub
    Function checkInput(ByVal ma As String, ByVal ten As String) As Boolean
        Dim result As Boolean = True
        If ma = "" Then
            MessageBox.Show("Bạn chưa chọn Mã  !")
            result = False
        Else
            If ten = "" Then
                MessageBox.Show("Bạn chưa nhập tên !")
                result = False
            End If
        End If
        Return result
    End Function
    Private Sub loadDanhSachNhomHangHoa(ByVal sqlQuery As String)
        Me.DataGridView1.DataSource = moduleDatabaseConn.GetDataTable(sqlQuery)
    End Sub

    Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        Dim iRow As Integer = Me.DataGridView1.CurrentRow.Index
        If iRow >= 0 Then
            Me.txtSophieu.Text = Me.DataGridView1.Item(Me.colsophieu.Index, iRow).Value
            Me.txtngayct.Text = Me.DataGridView1.Item(Me.colNgayct.Index, iRow).Value

            Me.cboMataisan.Text = Me.DataGridView1.Item(Me.colMataisan.Index, iRow).Value
            Me.txtTentaisan.Text = Me.DataGridView1.Item(Me.colTentaisan.Index, iRow).Value
            If Me.DataGridView1.Item(Me.colTanggiam.Index, iRow).Value = "tang" Then
                Me.CboTanggiam.Text = "Ghi tăng"
            End If
            If Me.DataGridView1.Item(Me.colTanggiam.Index, iRow).Value = "giam" Then
                Me.CboTanggiam.Text = "Ghi giảm"
            End If

            Me.txtSoluong.Text = Format(CInt(Me.DataGridView1.Item(Me.colSoluong.Index, iRow).Value), "N0")
            Me.txtTrigia.Text = Format(CDec(Me.DataGridView1.Item(Me.colTrigia.Index, iRow).Value), "N0")
            Me.txtKhauhao.Text = Format(CDec(Me.DataGridView1.Item(Me.colKhauhao.Index, iRow).Value), "N0")


            Me.txtDiengiai.Text = Me.DataGridView1.Item(Me.colDiengiai.Index, iRow).Value
            Me.txtGhiChu.Text = Me.DataGridView1.Item(Me.colGhichu.Index, iRow).Value
        End If
    End Sub
    Private Sub btn_cbo_nhom_taisan_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_cbo_nhom_taisan.Click
        co_tuoi = 1
        frmTS_Taisan.Show()
    End Sub
    Private Sub cboMataisan_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboMataisan.SelectedIndexChanged
        Try
            Me.txtTentaisan.Text = Me.cboMataisan.SelectedItem.Col2
            Me.txtDVT.Text = Me.cboMataisan.SelectedItem.Col3
        Catch ex As Exception
            Me.txtTentaisan.Text = ""
            Me.txtDVT.Text = ""
        End Try
    End Sub

    Private Sub txtTrigia_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTrigia.LostFocus
        Me.txtTrigia.Text = Format(CDec(Me.txtTrigia.Text), "N0")
    End Sub

    Private Sub txtKhauhao_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtKhauhao.LostFocus
        Me.txtKhauhao.Text = Format(CDec(Me.txtKhauhao.Text), "N0")
    End Sub
    Private Sub Btn_Edit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Edit.Click
        Me.setReadonly(False, True, True)
    End Sub

    Private Sub Btn_Lamtuoi_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Lamtuoi.Click
        If co_tuoi = 1 Then
            Me.loadTaisan()
        End If
        If co_tuoi = 0 Then
            Me.loadDanhSachNhomHangHoa("SELECT * FROM TS_tanggiam ")
        End If
    End Sub
End Class


